package com.wpre.seleniumtest.utils;

import io.github.bonigarcia.wdm.WebDriverManager;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: LianBao
 * Date: 2025-03-28
 * Time: 10:57
 */
public class DriverUtil {

    /**
     * @param url 网站url
     * @return 返回WebDriver对象
     */
    public static WebDriver createDriver(String url) {
        WebDriver driver = null;
        //1.打开浏览器
        //选择对应的浏览器驱动
        WebDriverManager.chromedriver().setup();
        //创建驱动对象要强制指定允许访问所有链接,所以需要增加浏览器配置
        ChromeOptions options = new ChromeOptions();
        options.addArguments("--remote-allow-origins=*");


        driver = new ChromeDriver(options);//驱动对象
        driver.get(url);
        driver.manage().window().maximize();//最大化
        return driver;
    }
}
